package com.china.school.Pointcut的12种用法;

import com.china.school.pojo.User;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;


@Aspect
@ComponentScan({"com.china.school"}) //<context:component-scan base-package="xx"/>
@EnableAspectJAutoProxy
public class ATargetTest {


    /**

     */
    public static void main(String[] args) {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ATargetTest.class);
        User user = ctx.getBean(User.class);
        user.eat();

    }




    /**
     匹配到类级别
     */
    @Around("@target(com.china.school.MyAnno)")
    public void around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("------around---前------" + joinPoint.getClass());

        if(joinPoint.getArgs().length == 0){

            joinPoint.proceed( );
        }else {
            joinPoint.proceed(  );

        }
        System.out.println("------around-----后----" + joinPoint.getClass());

    }







}
